import { queryPageList,queryColumnList,queryLevelList,queryTypeCodeList,queryDatabaseList} from '@/services/sensitiveData/scanTable';

export default {
  namespace: 'scanTable',
  state: {
    // 列表数据
    data: {
      dataList: [],
      pageNum: 0,
      pageSize: 0,
      totalCount: 0,
    }, 
    dataColumn: {
      dataList: [],
    },
    levelListData:{},
    typeCodeListData:{},
    databaseListData:{}, 
    queryForm:{},
  },
  effects: {
    *queryList({ payload }, { call, put }) {
      const response = yield call(queryPageList, payload);
      yield put({
        type: 'save',
        payload: response,
      });
      if (callback) callback(response);
    },

    *queryColumnList({ payload }, { call, put }) {
      const response = yield call(queryColumnList, payload);
      yield put({
        type: 'saveColumn',
        payload: response,
      });
    },


    *selectLevelList({ payload,callback }, { call, put }) {
      const response = yield call(queryLevelList, payload);
      yield put({
        type: 'saveLevel',
        payload: response,
      });
      if (callback) callback(response);
    },//查询分级

    *selectTypeCodeList({ payload,callback }, { call, put }) {
      const response = yield call(queryTypeCodeList, payload);
      yield put({
        type: 'saveType',
        payload: response,
      });
      if (callback) callback(response);
    },//查询分类

    *selectDatabaseList({ payload,callback }, { call, put }) {
      const response = yield call(queryDatabaseList, payload);
      yield put({
        type: 'saveDatabase',
        payload: response,
      });
      if (callback) callback(response);
    },//查询数据库    

  },

  reducers: {
    save(state, action) {
      return {
        ...state,
        data: action.payload.data || [],
      };
    }, 


    saveColumn(state, action) {
      return {
        ...state,
        dataColumn: action.payload.data || [],
      };
    }, //查看列

    saveLevel(state, action) {
      return {
        ...state,
        levelListData: action.payload.data || [],
      };
    }, //分级

    saveType(state, action) {
      return {
        ...state,
        typeCodeListData: action.payload.data || [],
      };
    }, //分类

    saveDatabase(state, action) {
      return {
        ...state,
        databaseListData: action.payload.data || [],
      };
    }, //数据库

  },
};
